﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using System.Web.Configuration;
using System.IO;

namespace HotelBrisaYArenaAdministrador
{
    public partial class IngresarFacilidad : System.Web.UI.Page
    {
        SeccionBusiness seccionBusiness = new SeccionBusiness(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
        ImagenBusiness imagenBusiness = new ImagenBusiness(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
        int idImagen;
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            String descripcion = TextBox1.Text;
            if (FileUpload1.HasFile)
            {
                using (BinaryReader reader = new BinaryReader(FileUpload1.PostedFile.InputStream))
                {
                    byte[] image = reader.ReadBytes(FileUpload1.PostedFile.ContentLength);
                    idImagen = imagenBusiness.GuardarImagen(image);
                }
            }

            seccionBusiness.IngresarSeccion(3, idImagen, descripcion);
            Response.Redirect("PaginaPrincipal.aspx");
        }
    }
}